<template>
  <div class="bigRight">
    <div class="bg">
      <div class="title d-flex">
        <span class="text">年龄段分布</span>
        <div class="line">
          <dv-decoration-3 class="dv-dec-3" />
        </div>
      </div>
      <dv-decoration-2 class="line2"/>
      <div class="d-flex" style="position: relative">
        <dv-active-ring-chart :config="config" class="ringChart" />
        <div class="label-tag">
          <div class="label-item" v-for="(label, i) in config.data" :key="i">
            <div :style="`background-color: ${config.color[i % config.color.length]};`" />{{ label.name }}<span>{{ label.value }}</span>人
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'bigRight2',
    props: {
      data: {
        type: Array,
        default: () => []
      }
    },
    data () {
      return {
        config: { }
      }
    },
    watch: {
      data: {
        handler (newData) {
          this.config = {
            radius: '70%',
            activeRadius: '75%',
            data: newData,
            color: ['#37a2da', '#32c5e9', '#67e0e3', '#9fe6b8', '#ffdb5c', '#ff9f7f'],
            digitalFlopStyle: {
              fontSize: '0.4rem'
            },
            lineWidth: 14
          }
        },
        immediate: true,
        deep: true
      }
    }
  }
</script>

<style scoped lang="less">
  .bigRight {
    width: 100%;
    height: 100%;
    padding: 20px 14px 15px;
    box-sizing: border-box;
    overflow: hidden;
    .bg {
      border-radius: 12px;
      background: rgba(35, 62, 249, 0.2);
      height: 100%;
      padding: 10px;
      box-sizing: border-box;
    }
    .title { position: relative;
      .text {
        color: #e4ebfb;
        font-size: 20px;
      }
      .line {
        width: 100px; height: 30px; margin-left: 10px;
        .dv-dec-3 {
          position: relative;
          width: 100%;
          height: 100%;
        }
      }
    }
    .line2 {width:100%;height:5px;margin-top: 6px}
    .ringChart { width: 240px; height: 260px;}
    .label-tag {
      width: calc( 100% - 242px);
      justify-content: center;
      align-items: center;
      position: absolute;
      top: 50%;
      right: 0;
      transform: translate(0, -50%);
      .label-item {
        margin: 5px;
        font-size: 17px;
        display: flex;
        align-items: center; color: #fff;
        span{ font-weight: bold; margin-left: 10px;}
        div {
          width: 12px;
          height: 12px;
          margin-right: 5px;
        }
      }
    }
  }
  .d-flex { display: flex;}
</style>
